#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 6;
struct Car{
    int d, v, a;
    double reach_t;
}car[N];
int T, n, m, L, V, p[N];
set<int> pr[N], st[N];
bool vis[N];
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%d", &T);
    while(T --){
        scanf("%d%d%d%d", &n, &m, &L, &V);
        for(int i = 1, d, v, a; i <= n; ++ i){
            scanf("%d%d%d", &d, &v, &a);
            car[i] = {d, v, a, (a != 0 ? d * 1.0 + (V * V - v * v) * 1.0 / (2 * a * 1.0) : (v <= V ? 1e9 : d))};
            vis[n] = 0;

        }
        for(int i = 1; i <= m; ++ i) scanf("%d", &p[i]), pr[i].clear();;
        int ct = 0;
        for(int i = 1; i <= n; ++ i){
            int k1 = lower_bound(p+1, p+1+m, car[i].d) - p;
            int k2 = lower_bound(p+1, p+1+m, car[i].reach_t) - p;
            if(car[i].a >= 0 && k2 != m+1){
                if(p[k2] == car[i].reach_t) ++ k2;
                ++ ct;
                for(int j = k2; j <= m; ++ j) pr[j].insert(i), st[i].insert(j);
            }
            else if(car[i].a < 0 && k2 - k1 >= 1 && k1 != m+1){
                if(p[k2] == car[i].reach_t) -- k2;
                for(int j = k1; j <= k2; ++ j) pr[j].insert(i), st[i].insert(j);
                ++ ct;
            }
        }
        printf("%d\n", ct);
        /*for(int i = 1; i <= n; ++ i){
            cout << pr[i].first <<  " " << pr[i].second << '\n';
        }*/

        //ct = 0;
    }
    return 0;
}
